home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-serious-
/
programming
/
other
/
littelcomp
/
r5
/
lc
/
examples
/
ptrs.library.l
< prev
next >
Wrap
Text File
|
2000-02-28
|
2KB
|
69 lines
//
// LITTEL v0.12 Example of using PTRs ..rewritten to 0.13b, 0.16b//
// extended to shared library, just for fun //
#mode LIBRARY 37 1 "ptrs.library" "ptrs.library by me 99"
#link library.lib
#fdef bubblesort2
#fdef fill_longarray_with_words
#endfdef _PtrsBase
#equ Useful 10
#equ NotUseful 0
#equ LongSize 4
#equ WordSize 2
// remember : youre only allowed to use D0-D5/A0-A3 ! //
// if itsnot a special case like, just before CALLing or DOPROCing //
PROC bubblesort2 // Array Of Long -> D0, Len -> D1
VAR end // declare a variabel (local)
CODESTART
COPY D0 end
ADD D1 end
DEC LongSize end
REPEAT
COPY NotUseful D2
COPY D0 A0
REPEAT
IF A0[] GT A0[].LongSize // GT : Greater Then
SWAP A0[] A0[].LongSize // Aaah..mmm.. swap.. :)
COPY Useful D2
ELSE
ENDIF
INC LongSize A0
ENDREPEAT A0 EQ end
ENDREPEAT D2 EQ NotUseful
ENDPROC
// NOTE : for speed reasons we use Ax and Dx Registers here.. //
// but we could have done it in exactly the same way usin just //
// local vars, they can also work as PTRs : myvar[]. //
// Remeber! : You are only Allowed to Use D0-D5, A0-A3! //
// but hey.. variables arent THAT slow anyway .. //
// another example.. //
PROC fill_longarray_with_words // longarray -> D0, wordarray -> D1, nrofwords -> D2
VAR larray // local vars
VAR warray // always LONGs as u know, I hope.
VAR len //
CODESTART
COPY D0 larray // copying some regs to som vars..
COPY D1 warray //
COPY D2 len //
WHILE len GT 0 // while len > 0
COPY warray[W] larray[L]
INC WordSize warray // add 2 to warray
INC LongSize larray // add 4 to larray
DEC 1 len // sub 1 from len
ENDWHILE
ENDPROC
END